#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 2e5 + 10, INF = 0x3f3f3f3f;

int n;
string s;
int a[N], f[N][2];

int hs(char c) { if (c == 'R') return 0; if (c == 'S') return 1;  return 2; }

int win(int x) { return (x + 2) % 3; }
int pin(int x) { return x; }

void solve()
{
    cin >> n >> s;
    for (int i = 1;i <= n;i++)
        a[i] = hs(s[i - 1]);

    f[1][0] = 0;f[1][1] = 1;
    for (int i = 2;i <= n;i++) {
        if (pin(a[i - 1]) != pin(a[i]))
            f[i][0] = max(f[i][0], f[i - 1][0]);
        if (win(a[i - 1]) != pin(a[i]))
            f[i][0] = max(f[i][0], f[i - 1][1]);
        if (pin(a[i - 1]) != win(a[i]))
            f[i][1] = max(f[i][1], f[i - 1][0] + 1);
        if (win(a[i - 1]) != win(a[i]))
            f[i][1] = max(f[i][1], f[i - 1][1] + 1);
    }
    // for (int i = 1;i <= n;i++) cout << a[i] << " ";
    cout << max(f[n][0], f[n][1]);
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}

//1 2 0 2 1 0 0 0 0 0 2 2 0 2 0 2 1 1 0 1 2 0 1 1
//0 1 2 1 0 2 0 2 0 2 1 2 0 1 2 1 0 1 2 0 1 2 0 1
//            0   0     0 0          0          0